from django.contrib.contenttypes.fields import GenericRelation
from django.db import models
from django.shortcuts import reverse
from django.utils.translation import gettext_lazy as _
from lib.django import models as mymodels
from media.models import File
from .project import Project

from .lib import ProjectSubMixin

class Beginning(ProjectSubMixin, models.Model):
    project = models.OneToOneField(
        verbose_name=_("项目"),
        to=Project,
        on_delete=models.CASCADE,
    )

    date_of_national_kickoff = models.DateField(
        verbose_name=_('全国启动会召开时间'), 
        null=True, 
        blank=True,
        default=None
    )
    
    date_of_plantraining = models.DateField(
        verbose_name=_('方案/量表一致性培训时间'), 
        null=True, 
        blank=True,
        default=None
    )
    
    date_of_center_kickoff = models.DateField(
        verbose_name=_('本中心启动会时间'), 
        null=True, 
        blank=True,
        default=None
    )
    
    participants_names = models.CharField(
        verbose_name=_('机构办参加人员名单'),
        max_length=255,
        blank=True,
        default='',
        help_text=_('名字之间可以用逗号分隔')
    )
    
    is_completed_record = models.BooleanField(
        verbose_name=_('机构会议记录是否完成'),
        default=False
    )
    
    is_completed_form = models.BooleanField(
        verbose_name=_('分工授权表是否完成'),
        default=False
    )
    
    note = models.TextField(
        verbose_name=_('备注'),
        blank=True,
        default=''
    )

    class Meta:
        default_permissions = []
        db_table = "project_beginning"
        verbose_name = _("项目启动")
        verbose_name_plural = verbose_name

    @classmethod
    def get_link(cls, project_id, id):
        return reverse("project:beginning/detail", kwargs={'project_pk': project_id})

